// 导入组件
import Vue from 'vue';
import Router from 'vue-router';
// 首页
import index from '@/views/index';

import error from '@/components/error';

//视频
import videos from "@/views/videos";
//资讯
import articles from "@/views/articles";
//关于我们
import about from "@/views/about";

//个人中心
import users from "@/views/users/users";
//我的信息
import detail from "@/views/users/detail";
//我的头像
import avatar from "@/views/users/avatar";
//视频管理
import manage from "@/views/users/manage";
//上传视频
import uploads from "@/views/users/uploads";
//查看记录
import aboutme from "@/views/users/aboutme";
//投稿规范
import norm from "@/views/users/norm";

//视频详情
import videoDetail from "@/views/video/videoDetail"

import admin from "@/views/admin/admin";
import userAdmin from "@/views/admin/userAdmin";
import videoAdmin from "@/views/admin/videoAdmin";
import articleAdmin from "@/views/admin/articleAdmin";

// 启用路由
Vue.use(Router);

// 导出路由
export default new Router({
    routes: [{
        path: '/',
        name: '首页',
        component: index,
        hidden: true,
        meta: {
            requireAuth: false
        },
        children: [
            {
                path: '/',
                name: '视频',
                component: videos,
                meta: {
                    requireAuth: true
                }
            }, {
                path: '/articles',
                name: '资讯',
                component: articles,
                meta: {
                    requireAuth: true
                }
            }, {
                path: '/about',
                name: '关于我们',
                component: about,
                meta: {
                    requireAuth: true
                }
            }, {
                path: '/users',
                name: '个人中心',
                component: users,
                redirect:'/users/detail',
                meta: {
                    requireAuth: false
                },
                children: [
                    {
                        path: '/users/detail',
                        name: '我的信息',
                        component: detail,
                        meta: {
                            requireAuth: true
                        }
                    }, {
                        path: '/users/avatar',
                        name: '我的头像',
                        component: avatar,
                        meta: {
                            requireAuth: true
                        }
                    }, {
                        path: '/users/uploads',
                        name: '上传视频',
                        component: uploads,
                        meta: {
                            requireAuth: true
                        }
                    }, {
                        path: '/users/manage',
                        name: '视频管理',
                        component: manage,
                        meta: {
                            requireAuth: true
                        }
                    }, {
                        path: '/users/aboutme',
                        name: '查看记录',
                        component: aboutme,
                        meta: {
                            requireAuth: true
                        }
                    }, {
                        path: '/users/norm',
                        name: '投稿规范',
                        component: norm,
                        meta: {
                            requireAuth: true
                        }
                    }
                ]
            }, {
                path: '/videos',
                name: '视频',
                component: videoDetail,
                redirect:'/videos/videoDetail',
                meta: {
                    requireAuth: false
                },
                children: [
                    {
                        path: '/videos/videoDetail',
                        name: '视频详情',
                        component: videoDetail,
                        meta: {
                            requireAuth: true
                        }
                    },
                ]
            }
        ]
    }, {
      path: '/error',
      name: '404',
      component: error,
      hidden: true,
      meta: {
        requireAuth: false
      }
    }, {
        path: '/admin',
        name: '管理员界面',
        component: admin,
        hidden: true,
        meta: {
            requireAuth: false
        },
        redirect:'/admin/userAdmin',
        children: [
            {
                path: '/admin/userAdmin',
                name: '用户管理',
                component: userAdmin,
                meta: {
                    requireAuth: true
                }
            }, {
                path: '/admin/videoAdmin',
                name: '视频管理',
                component: videoAdmin,
                meta: {
                    requireAuth: true
                }
            }, {
                path: '/admin/articleAdmin',
                name: '公告管理',
                component: articleAdmin,
                meta: {
                    requireAuth: true
                }
            }
        ]
    }, {
        path: '*',
        redirect: '/'
    }]
})
